//
//  ShellOrderDetailViewController.m
//  ShellWallert
//
//  Created by lvzhao on 2019/10/2.
//  Copyright © 2019 VV. All rights reserved.
//

#import "ShellOrderDetailViewController.h"
#import "ShellOrderDetailView.h"
#import "ShellOrderViewModel.h"



@interface ShellOrderDetailViewController ()
@property (nonatomic,strong) ShellOrderDetailView *detailView;

@property (nonatomic,strong) ShellOrderViewModel *viewModel;
@end

@implementation ShellOrderDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = LZLocalizedString(@"订单详情");
    // Do any additional setup after loading the view.
    [self setupUI];
}

- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    //查看堆栈, 看是否有该VC
    NSArray * navs = self.navigationController.viewControllers;
    BOOL isDispose = YES;
    for (UIViewController * vc in navs){
        NSString * VCString =  NSStringFromClass([vc class]);
        NSString * orderVCString =  NSStringFromClass([self class]);
        if([VCString isEqualToString:orderVCString]){
            isDispose = NO;
        }
    }
    if(isDispose) {
        //释放定时器
        [self.detailView.disposable dispose];
        self.detailView.disposable = nil;
    }
}

#pragma mark - setupUI
- (void)setupUI{
    [self.view addSubview:self.detailView];
    [self.detailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    
    //订单详情
    [self.viewModel getOrderDetail];
}

#pragma mark - actions

#pragma mark - custool

#pragma mark - get && set
- (ShellOrderDetailView *)detailView{
    
    if(!_detailView){
        _detailView = [[ShellOrderDetailView alloc] initViewModel:self.viewModel];
    }
    return _detailView;
}

- (ShellOrderViewModel *)viewModel{
    if(!_viewModel){
        _viewModel = [[ShellOrderViewModel alloc] init];
        _viewModel.orderModel = self.orderModel;
    }
    return _viewModel;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
